<template>
	<div class="wrapper">
		<div style="width: 700px;">
			<el-form :model="addForm" label-width="80px">
				<el-form-item label="学生名称">
					<el-input v-model="addForm.nickname" size="small" placeholder="请输入名称,最多可添加15个字"></el-input>
				</el-form-item>
				<el-form-item label="学生手机号">
					<el-input size="small" v-model="addForm.mobile" placeholder="请输入手机号"></el-input>
				</el-form-item>
				<el-form-item label="学员头像">
					<!-- <el-upload class="upload-demo" :action="uploadURL" :headers="headerObj" list-type="picture"
						:on-success="handleSuccess">
						<el-button size="small" type="primary">点击上传</el-button>
						<div slot="tip" class="el-upload__tip">只能上传jpg/png文件，且不超过500kb</div>
					</el-upload> -->
				</el-form-item>
				<el-form-item label="性别">
					<!-- <el-select v-model="addForm.sex" size="small" placeholder="请选择">
						<el-option :value="index" v-for="(item,index) in option" :key="index" :label="item.label">
						</el-option>
					</el-select> -->
				</el-form-item>
				<el-form-item label="出生日期">
					<el-col :span="11">
						<el-date-picker size="small" type="date" placeholder="选择日期" v-model="addForm.birthday"
							style="width: 100%;">
						</el-date-picker>
					</el-col>
				</el-form-item>
				<el-form-item label="所在城市">
					<!-- <el-select size="small" v-model="addForm.province_id" placeholder="请选择">
						<el-option :value="item.id" v-for="(item,index) in cityList" :key="index"
							:label="item.area_name">
						</el-option>
					</el-select> -->

					<!-- <el-select size="small" v-model="addForm.city_id" placeholder="请选择">
						<el-option value="a">
						</el-option>
					</el-select>

					<el-select size="small" v-model="addForm.district_id" placeholder="请选择">
						<el-option value="a">
						</el-option>
					</el-select> -->
				</el-form-item>
				<el-form-item label="111">
					<el-input size="small" placeholder="请选择"></el-input>
				</el-form-item>
				<el-form-item>
					<el-button type="primary" size="small" @click="addUser('addFormRef')">保存</el-button>
				</el-form-item>
			</el-form>
		</div>
	</div>
</template>

<script>
	export default {
		// 组件名称
		name: 'demo',
		// 组件参数 接收来自父组件的数据
		props: [],
		// 局部注册的组件
		components: {},
		// 组件状态值
		data() {
			return {
				// 添加用户的参数
				addForm: {
					avatar: "", //是	string	头像
					birthday: "", //是	string	生日日期
					province_id: "", //是	string	省ID
					city_id: "", //string	城市ID
					district_id: "", //是	string	地区ID
					mobile: "", //string	手机号码
					nickname: "", //是	string	姓名
					sex: "",
					// // 上传的图片临时路径（对象）
					// pics: [],
				},
				// // 图片上传地址
				// uploadURL: "http://120.53.31.103:84/api/public/img",
				// // 图片上传组件的请求对象
				// headerObj: {
				// 	Authorization: 'Bearer' + sessionStorage.getItem("school_token"),
				// },
				// // cityList: []
			}
		},
		mounted() {},
		// 计算属性
		computed: {},
		// 侦听器
		watch: {},
		// 组件方法
		methods: {
			// handleSuccess(response) {
			// 	console.log(response)
			// 	// let imageInfo={pic:response.data.path};
			// 	// this.pics.push(imageInfo)
			// },

			async addUser() {
					try {
						const {
							data: res
						} = await this.$http.post("user",this.addForm)
						console.log(res)
						// if (res.code !== 200) {
						// 	return this.$message.error(res.msg)
						// }
						// this.$message.success(res.msg)
						// this.$router.push('/Student')
					} catch (e) {
						console.log(e)
					}
			},
			// 获取城市的数据列表
			// async getCityList() {
			// 	try {
			// 		const {
			// 			data: res
			// 		} = await this.$http.get('sonArea/id');
			// 		console.log(res)
			// 		this.cityList = res.data;
			// 	} catch (e) {
			// 		this.$message.error(e)
			// 	}
			// }
		},
		/**
		 * 组件实例创建完成
		 */
		created() {
			// this.getCityList();
		},
	}
</script>

<style scoped>
	.el-upload {
		width: 60px;
	}
</style>
